#
# Copyright (C) 2015 OpenWrt-dist
#
# This is free software, licensed under the MIT.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=chinadns
PKG_VERSION:=1.3.1
PKG_RELEASE:=1

PKG_SOURCE:=ChinaDNS-$(PKG_VERSION).tar.gz
#PKG_SOURCE_URL:=https://github.com/aa65535/openwrt-chinadns/releases/download/v$(PKG_VERSION)/$(PKG_SOURCE)
PKG_SOURCE_URL:=https://github.com/aa65535/openwrt-chinadns/releases/download/v$(PKG_VERSION)/
PKG_MD5SUM:=a68bd997f3d69291605f69e93c1514c2
PKG_BUILD_DIR:=$(BUILD_DIR)/ChinaDNS-$(PKG_VERSION)

PKG_INSTALL:=1
PKG_FIXUP:=autoreconf
PKG_USE_MIPS16:=0
PKG_BUILD_PARALLEL:=1

include $(INCLUDE_DIR)/package.mk


define Package/chinadns
  CATEGORY:=Firefly Configuration
  SUBMENU:=Applications
  TITLE:=chinaDNS
endef

define Package/chinadns/conffiles
/etc/config/chinadns
/etc/chinadns_iplist.txt
/etc/chinadns_chnroute.txt
endef

define Package/chinadns/install
	$(INSTALL_DIR) $(1)/etc/init.d
	$(INSTALL_BIN) ./files/chinadns.init $(1)/etc/init.d/chinadns
	$(INSTALL_CONF) $(PKG_BUILD_DIR)/iplist.txt $(1)/etc/chinadns_iplist.txt
	$(INSTALL_CONF) $(PKG_BUILD_DIR)/chnroute.txt $(1)/etc/chinadns_chnroute.txt
	$(INSTALL_DIR) $(1)/etc/config
	$(INSTALL_DATA) ./files/chinadns.config $(1)/etc/config/chinadns
	$(INSTALL_DIR) $(1)/usr/bin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/chinadns $(1)/usr/bin
endef

$(eval $(call BuildPackage,chinadns))
